﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Guia.Elements;
using Guia.Core;
using System.Windows.Automation;
using WpfTestApplication;

namespace NUnitTests{
    /// <summary>
    /// Summary description for ToggleButtonTest
    /// </summary>
    [TestFixture]
    public class ToggleButtonTest : AbstractWindowTest
    {
        [Test]
        public void TestToggle2State()
        {
            ToggleButton toggleButton = window.Get<ToggleButton>("toggleButton1");
            Assert.IsTrue(toggleButton.IsOff);
            Assert.IsFalse(toggleButton.IsOn);
            Assert.IsFalse(toggleButton.IsIndeterminate);

            toggleButton.Toggle();
            Assert.IsTrue(toggleButton.IsOn);
            Assert.IsFalse(toggleButton.IsOff);
            Assert.IsFalse(toggleButton.IsIndeterminate);

            toggleButton.Toggle();
            Assert.IsTrue(toggleButton.IsOff);
            Assert.IsFalse(toggleButton.IsOn);
            Assert.IsFalse(toggleButton.IsIndeterminate);
        }

        [Test]
        public void TestToggle3State()
        {
            ToggleButton toggleButton = window.Get<ToggleButton>("toggleButton2");
            Assert.IsTrue(toggleButton.IsOff);
            Assert.IsFalse(toggleButton.IsOn);
            Assert.IsFalse(toggleButton.IsIndeterminate);

            toggleButton.Toggle();
            Assert.IsTrue(toggleButton.IsOn);
            Assert.IsFalse(toggleButton.IsOff);
            Assert.IsFalse(toggleButton.IsIndeterminate);

            toggleButton.Toggle();
            Assert.IsTrue(toggleButton.IsIndeterminate);
            Assert.IsFalse(toggleButton.IsOff);
            Assert.IsFalse(toggleButton.IsOn);

            toggleButton.Toggle();
            Assert.IsTrue(toggleButton.IsOff);
            Assert.IsFalse(toggleButton.IsOn);
            Assert.IsFalse(toggleButton.IsIndeterminate);
        }

        [Test,ExpectedException(typeof(OperationNotSupportedException))]
        public void TestToggleDisabled()
        {
            ToggleButton toggleButton = window.Get<ToggleButton>("toggleButton3");
            toggleButton.Toggle();
        }

        protected override Type TestWindowType()
        {
            return typeof(ToggleButtonTestWindow);
        }

        protected override string TestWindowName()
        {
            return "ToggleButtonTestWindow";
        }
    }
}
